<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.net.URLDecoder"%>
<%@ page language="java" import="nix.demo2.domain.User"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'login.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%
		Locale locale = request.getLocale();
		ResourceBundle rb = ResourceBundle.getBundle("res", locale);
	%>
	<h1><%=rb.getString("login") %></h1>
	<c:remove var="session_user" />
	<%
		String username = "";
		Cookie[] cs = request.getCookies();
		if (cs != null) {
			for (Cookie c : cs) {
				if ("cookie_username".equals(c.getName())) {
					username = URLDecoder.decode(c.getValue(),
							"utf-8");
				}
			}
		}
		
		User user = (User)request.getAttribute("user");
		if (user != null) {
			username = user.getUsername();
		}
	%>
	<form action="<c:url value='/demo2/LoginServlet'/>" method="post">
		<%=rb.getString("username") %>：<input type="text" name="username" value="<%=username %>" />
		<font style="color: red;">${errors.username }${msg }</font><br />
		<%=rb.getString("password") %>：<input type="password" name="password" value="${user.password }" />
		<font style="color: red;">${errors.password }</font><br /> 
		<input type="submit" value="<%=rb.getString("login") %>" />
	</form>
</body>
</html>
